package thread;

public class MyThread extends Thread{
    private String name;
    public MyThread(){

    }
    public MyThread(String name) {
        super(name);
    }
    @Override
    //重写run()方法，所有要执行的代码，都要写在run方法中，
    // 然后调用start()方法启动线程
    public void run(){
        System.out.println("线程的任务");
        //休眠
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //执行线程的任务
        for (int i = 0; i < 100; i++) {
            //Thread.currentThread()  获取当前线程    返回结果是 Thread-0数字
            System.out.println(Thread.currentThread().getName() + i);
        }
    }
}
